package com.mlethe.calendarview

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import com.mlethe.calendarview.databinding.ActivityMainBinding
import com.mlethe.library.calendarview.Calendar
import com.mlethe.library.calendarview.CalendarView
import com.mlethe.library.calendarview.CalendarView.OnCalendarSelectListener

class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.calendarView.setOnScrollOutRangeListener(object:
            CalendarView.OnScrollOutRangeListener {
            override fun onScrolledToFirstPage() {
                Toast.makeText(this@MainActivity, "已滑动到第一页了", Toast.LENGTH_SHORT).show()
            }

            override fun onScrolledToLastPage() {
                Toast.makeText(this@MainActivity, "已滑动到最后一页了", Toast.LENGTH_SHORT).show()
            }
        })

        binding.calendarView.setOnMonthChangeListener { year, month ->
            Log.d("yym", "onCreate: year->$year, month->$month")
        }
        binding.calendarView.setOnCalendarSelectListener(object : OnCalendarSelectListener {
            override fun onCalendarOutOfRange(calendar: Calendar) {
                Log.e("yym", "onCalendarOutOfRange: calendar->$calendar")
            }

            override fun onCalendarSelect(calendar: Calendar, isClick: Boolean) {
                Log.e("yym", "onCalendarSelect: calendar->$calendar, week->${calendar.week}, isClick->$isClick")
            }

        })

        binding.llBase.setOnClickListener {
            val intent = Intent(this, NormalActivity::class.java)
            startActivity(intent)
        }

        binding.llWeek.setOnClickListener {
            val intent = Intent(this, MonthWeekActivity::class.java)
            startActivity(intent)
        }

    }
}